package com.chinasofti.framework.dataaccess;

import java.lang.reflect.Type;

import com.chinasofti.framework.data.Entity;
import com.chinasofti.framework.dataaccess.Filter.Relation;
import com.chinasofti.framework.parser.XmlParser;

/**
 * @author yaoyang
 *
 * @date 2011-11-23
 */
public class FilterParser extends XmlParser<Filter>{

	@Override
	protected Object getValueFromText(Entity entity, String attrName, Type type, String text) {
		Object object = super.getValueFromText(entity, attrName, type, text);
		if(object != null) {
			return object;
		}
		
		if(type == Relation.class) {
			object = Relation.valueOf(text);
		}
		return object;
	}

	@Override
	protected Filter createEntityInstance() {
		return new Filter();
	}
}
